package ace.cmp.converter.spring.autoconfig;

import ace.cmp.converter.api.AceConverter;
import ace.cmp.converter.spring.core.ConverterFactory;
import ace.cmp.converter.spring.core.ConverterServiceImpl;
import ace.cmp.converter.spring.core.impl.ConverterFactoryImpl;
import java.util.List;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author caspar
 * @date 2023/4/4 15:01
 */
@Configuration
public class SpringBeanCopierAutoConfig {
  @ConditionalOnMissingBean
  @Bean
  public ConverterServiceImpl converterService(
      List<AceConverter> converters, ConverterFactory converterFactory) {
    return new ConverterServiceImpl(converters, converterFactory);
  }

  @ConditionalOnMissingBean
  @Bean
  public ConverterFactory converterFactory() {
    return new ConverterFactoryImpl();
  }
}
